<?php

require_once dirname(__FILE__).'/../lib/vendor/symfony/lib/autoload/sfCoreAutoload.class.php';
sfCoreAutoload::register();

class ProjectConfiguration extends sfProjectConfiguration
{
  public function setup()
  {
    $this->enablePlugins('sfDoctrine2Plugin');
  }

  public function configureDoctrineConnection(\Doctrine\ORM\Configuration $config)
  {
    // Decide where you want the proxy classes to be stored, and which namespace they should use
    $config->setProxyDir(sfConfig::get("sf_cache_dir")."/Proxies");
    $config->setProxyNamespace("Proxies");

    // You may want to make this environment specific for performance reasons
    $config->setAutoGenerateProxyClasses(false);
    //$config->setSqlLogger(null);

    // This will get things working, but later you will want to use APC
    // or another "real" cache for production
    $cache = new \Doctrine\Common\Cache\ArrayCache;
    $reader = new \Doctrine\Common\Annotations\AnnotationReader($cache);
    $config->setMetadataCacheImpl($cache);
    $config->setQueryCacheImpl($cache);

    // Tell Doctrine where to find your entities (you may have more than one location)
    // This is mostly required for cli tasks that iterate over all of your entities
    $paths = array(sfConfig::get("sf_lib_dir") . "/Entities"); // Populate this with all the locations of your entities
    $reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');
    $annotation = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, $paths);
    $config->setMetadataDriverImpl($annotation);

    // Register all the classes that Doctrine needs to autoload

    $classLoader = new \Doctrine\Common\ClassLoader('Model');
    $classLoader->setIncludePath(sfConfig::get('sf_lib_dir'));
    $classLoader->register();

    $classLoader = new \Doctrine\Common\ClassLoader('Services');
    $classLoader->setIncludePath(sfConfig::get('sf_lib_dir'));
    $classLoader->register();

    $classLoader = new \Doctrine\Common\ClassLoader("Proxies");
    $classLoader->setIncludePath(sfConfig::get('sf_cache_dir'));
    $classLoader->register();
  }
}
